import { createSlice } from '@reduxjs/toolkit'

export const homeSlice = createSlice({
  name: 'home',
  initialState: {
    list: [],
  },
  reducers: {
    addItem: (state, action) => {
      state.list.push(action.payload)
    },
    removeItem: (state, action) => {
      const index = state.list.findIndex(item => item === action.payload)
      state.list.splice(index, 1)
    },
  },
})

export const { addItem, removeItem } = homeSlice.actions

export default homeSlice.reducer
